package com.example.struct;

import java.util.ArrayList;
/**
 * @author:我叫程晓非
 * @desc:一笔画顶点数据结构
 * @date:2021-11-07
 * @version:1.0
 */
public class Vertex{

    public int x;
    public int y;
    public boolean isVisited;
    public int index;
    public int degree;
    private ArrayList<Vertex> next = null;

    public Vertex()  // constructor
    {
        this.isVisited = false;
    }
    public Vertex(int level)  // constructor
    {
        this.isVisited = false;
    }
    //为节点添加邻接点
    public void addAdj(Vertex ver){
        if(next == null) next = new ArrayList<Vertex>();
        next.add(ver);
    }

    public ArrayList<Vertex> getAdj(){
        return next;
    }

    public void setIndex(int index,int row,int col){
        this.index = index;
        y = index/col;
        x = index%row;
    }



    public String toString(){
        return "[顶点 ("+x+","+y+"),下标："+index+"]";
    }
}
